from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
import time
d = webdriver.Chrome()
d.get('https://www.baidu.com')
d.maximize_window()
time.sleep(1)

input_ele = d.find_element(By.CSS_SELECTOR, '[id="kw"]')
time.sleep(1)
# 使用键盘操作 导入 Keys 模块
input_ele.send_keys('Python哈')
time.sleep(1)
input_ele.send_keys(Keys.BACK_SPACE)  # 删除
time.sleep(1)
input_ele.send_keys(Keys.ENTER)  # 回车
time.sleep(1)
time.sleep(10)
d.quit()